package com.ruoyi.web.controller.file;

import com.ruoyi.common.pub.vo.Response;
import com.ruoyi.system.service.ExcelImportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
public class ExcelImportController {

    @Autowired
    private ExcelImportService excelImportService;

    @PostMapping("/importExcel/product")
    public Response<String>importProduct(@RequestPart MultipartFile file,String pictruePath){
        try {
            excelImportService.importProduct(file,pictruePath);
        } catch (Exception e) {
            e.printStackTrace();
            return Response.failed().msg(e.getMessage());
        }
        return Response.success("导入成功");
    }
}
